#include "room.h"
#include <fstream>
#include <sstream>

Room::Room() {}
Room::Room(const std::string& num, const std::string& t, double p, const std::string& s)
: roomNumber(num), type(t), price(p), status(s) {}

void Room::saveToFile(const std::string& filename) const {
	std::ofstream file(filename.c_str());
	if (!file.is_open()) return;
	file << roomNumber << "\n" << type << "\n" << price << "\n" << status;
	file.close();
}

Room Room::loadFromFile(const std::string& filename) {
	std::ifstream file(filename.c_str());
	if (!file.is_open()) {
		return Room();
	}
	std::string num, t, s;
	double p;
	std::getline(file, num);
	std::getline(file, t);
	file >> p;
	file.ignore(); // skip newline
	std::getline(file, s);
	file.close();
	return Room(num, t, p, s);
}
